<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class major_model extends CI_Model {

    public function __construct() {
        error_reporting(0);
        parent::__construct();
    }
    
   public function getMajors(){
       return $this->db->select("*")->from("majors")->order_by("major_title","ASC")->get();
   }
   
   public function get_group_major_relation( $activity_id ){
       $this->db->select("*")
                      ->from("activity_groups_relation")
                      ->join("group_major_relation","group_major_relation.ref_activity_groups_relation_id = activity_groups_relation.ref_act_id","inner")
                      ->join("majors","majors.major_id = group_major_relation.ref_major_id","inner")
                      ->where("activity_groups_relation.ref_act_id",  $activity_id)
                      ->group_by("majors.major_id");
       return $this->db->get();
   }
   
   public function get_group_teacher_relation($activity_id){
       $this->db->select("*")
                      ->from("activity_groups_relation")
                      ->join("group_teacher_relation","group_teacher_relation.ref_activity_groups_relation_id = activity_groups_relation.activity_groups_relation_id","inner")
                      ->join("teachers","teachers.teacher_id = group_teacher_relation.ref_teacher_id","inner")
                      ->where("activity_groups_relation.ref_act_id",  $activity_id)
                     ->group_by("teachers.teacher_id");
         //     file_put_contents("ddd.txt", $this->db->_compile_select());
       return $this->db->get();
   }
    
}
?>
